home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / CMD / PLCMPDLG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-29  |  1.3 KB  |  53 lines

  1. /*
  2.  * the class CPlaceCompDialog
  3.  * Copyright (C) 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
  4.  */
  5.  
  6. #include "../stdafx.h"
  7. #include <afxdlgs.h>
  8.  
  9. #include "plcmpdlg.h"
  10.  
  11. BEGIN_MESSAGE_MAP(CPlaceCompDialog, CDialog)
  12.   ON_EN_CHANGE(IDC_COMP_NAME, OnChangeName)
  13.   ON_COMMAND(IDC_COMP_BROWSE, OnBrowse)
  14. END_MESSAGE_MAP()
  15.  
  16. BOOL CPlaceCompDialog::OnInitDialog(void)
  17. {
  18.   m_component_name.Empty();
  19.   m_designator.Empty();
  20.   ctlOKButton().EnableWindow(false);
  21.   CDialog::OnInitDialog();
  22.   return TRUE;
  23. }
  24.  
  25. void CPlaceCompDialog::DoDataExchange(CDataExchange* pDX)
  26. {
  27.   CDialog::DoDataExchange(pDX);
  28.   DDX_Text(pDX, IDC_COMP_NAME      , m_component_name);
  29.   DDX_Text(pDX, IDC_COMP_DESIGNATOR, m_designator    );
  30. }
  31.  
  32. void CPlaceCompDialog::OnChangeName(void)
  33. {
  34.   CString name;
  35.   ctlName().GetWindowText(name);
  36.   bool bEnableOK = (name.GetLength() != 0) ? true : false;
  37.   ctlOKButton().EnableWindow(bEnableOK);
  38. }
  39.  
  40. void CPlaceCompDialog::OnBrowse(void)
  41. {
  42.   CFileDialog dlg(TRUE, "cmp", m_component_name,
  43.     OFN_PATHMUSTEXIST | OFN_HIDEREADONLY,
  44.     "kban Component Files (*.cmp)|*.cmp|All Files (*.*)|*.*||",
  45.     this
  46.   );
  47.   if(dlg.DoModal() == IDOK) {
  48.     m_component_name = dlg.GetPathName();
  49.     CEdit& ctlFileName = *(CEdit*)GetDlgItem(IDC_COMP_NAME);
  50.     ctlFileName.SetWindowText(m_component_name);
  51.   }
  52. }
  53.